package com.lyouu.dataminer.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Random;

import com.lyouu.dataminer.db.DbConstants;
import com.lyouu.dataminer.factory.MysqlDbFactory;

public class MdPicturesDao {
	public int insert(int picId, int albumId, int sid, int uid, String username, String imgUrl)
			throws SQLException {
		Connection conn =  MysqlDbFactory.getConnection(DbConstants.DB_LYOUU);
		String sql = "INSERT INTO md_pictures (picid,albumid,city_id,sid,uid,username,title,thumb,width,height,addtime) VALUES (?,?,'1',?,?,?,?,?,240,180,?)";
		PreparedStatement stmt = conn.prepareStatement(sql);
		stmt.setInt(1, picId);
		stmt.setInt(2, albumId);
		stmt.setInt(3, sid);
		stmt.setInt(4, uid);
		stmt.setString(5, username);
		stmt.setString(
				6,
				String.valueOf(sid) + "_"
						+ String.valueOf(new Random().nextInt(90000) + 10000));
		stmt.setString(7, imgUrl);
		stmt.setInt(8, (int) (System.currentTimeMillis() / 1000));
		return stmt.executeUpdate();
	}
}
